package com.wms.mapper;

import com.wms.entity.WmsUser;
import com.wms.entity.WmsUserRole;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface UserRoleMapper {

    /**
     * 根据用户id查询角色id
     * @param user
     * @return
     */
    @Select("select * from wms_user_role where user_id = #{userId}")
    List<WmsUserRole> findRoleIdByUser(WmsUser user);

    /**
     * 新增
     * @param userId
     * @param roleId
     */
    @Insert("insert into wms_user_role(user_id, role_id) values(#{userId}, #{roleId})")
    void setUserRole(long userId, long roleId);

    /**
     * 修改
     * @param userId
     * @param roleId
     */
    @Update("update wms_user_role set role_id = #{roleId} where user_id = #{userId}")
    void update(long userId, long roleId);

    /**
     * 根据用户id删除
     * @param ids
     */
    void deleteByUserId(List<Long> ids);
}
